import { Injectable } from '@angular/core';
import { EntityConfig } from '../../core/entity-config.types';
import { PurchaseOrderTypeDto } from '../../proxy/joy/erp/basic-archives/procurements';
import { DatePipe } from '@angular/common';
import { LocalizationService } from '@abp/ng.core';

@Injectable({
  providedIn: 'root'
})
export class PurchaseOrderTypeConfigService {
  private datePipe = new DatePipe('zh-CN');

  constructor(private localization: LocalizationService) {}

  getConfig(): EntityConfig {
    return {
      entityType: 'Joy.Erp.BasicArchives.Procurements.PurchaseOrderType',
      propertys: [
        {
          name: 'Code',
          key: 'code',
          type: 'string',
          field: (item: PurchaseOrderTypeDto) => item.code,
          width: 200,
          show: true,
          order: 0,
          fixed: 0
        },      
        {
          name: 'DisplayName',
          key: 'displayName',
          type: 'string',
          field: (item: PurchaseOrderTypeDto) => item.displayName,
          width: 200,
          show: true,
          order: 1,
          fixed: 0
        },
        {
          name: 'CreationTime',
          key: 'creationTime',
          type: 'date',
          field: (item: PurchaseOrderTypeDto) => this.datePipe.transform(item.creationTime, 'yyyy-MM-dd'),
          width: 200,
          show: true,
          order: 3,
          fixed: 0
        },
      ]
    };
  }

  private l(key: string, ...params: string[]): string {
    return this.localization.instant(key, ...params);
  }
} 